package com.my.controller;

import com.my.config.RedisUtil;
import com.my.entity.UserInfo;
import com.my.service.ManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class HomeController {
    @Autowired
    RedisUtil redisUtil;

    @Autowired
    ManageService manageService;
    @RequestMapping("index")
    public List<UserInfo> index(){

        return manageService.getList();
    }
    @RequestMapping("delete")
    public String delete(long id){
        int delete = manageService.deleteUsserInfo(id);
        return "delete";
    }
    @RequestMapping("set")
    public  String set(){
        redisUtil.set("name","张三");
        redisUtil.set("age","19");
        redisUtil.set("score","100",30);
        return "dada";
    }

    @RequestMapping("get")
    public  String get(@RequestParam("key") String key){
    Object val = redisUtil.get(key);
    return val.toString();
    }
}
